/**
 * 带token和未登录的请求
 */
const request = axios.create({
    headers: {'token': sessionStorage.getItem("token")}
});

/**
 * 带token的json格式请求
 */
const requestJson = axios.create({
    headers: {
        'token': sessionStorage.getItem("token"),
        'Content-Type': 'application/json'
    }
});

const onError = function(error) {
    if (error.response.status === 401) {
        let msg = error.response.data.msg
        window.location.href="/login.html"
        sessionStorage.removeItem("token")
        sessionStorage.removeItem("user")
    }
}